<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>
        <a>下载</a>
    </div>
    <script>
        let content = "Blob Data";
        let blob = new Blob([content]);
        let link = document.getElementsByTagName('a')[0];
        link.download = 'file';
        link.href = URL.createObjectURL(blob);
        console.log(link)
        

        // downFile('asdasd','file');
        // function downFile(content, filename) {
        //     // 创建隐藏的可下载链接
        //     var eleLink = document.createElement('a');
        //     eleLink.download = filename;
        //     eleLink.style.display = 'none';
        //     // 字符内容转变成blob地址
        //     var blob = new Blob([content]);
        //     eleLink.href = URL.createObjectURL(blob);
        //     // 触发点击
        //     document.body.appendChild(eleLink);
        //     eleLink.click();
        //     // 然后移除
        //     document.body.removeChild(eleLink);
        // };

    </script>
</body>
</html>